<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="com.shsh.safemanage.model.User"%>

<div class="hider" id="hider">
	<span>&nbsp;</span>
</div>
<div class="position">
	<img src="../images/position2.jpg" style="padding: 7px 9px; float: left;" />当前位置：上海高桥分公司问题管理平台 &gt;&gt; 系统管理&gt;&gt; 职务(岗位)角色管理
</div>

<%
{
%>
<div class="tt">管理职务(岗位)与角色映射</div>
<div class="content">
	<table align="center" border="0" width="700" cellpadding="0"
		cellspacing="0">
		<tr>
			<td class="td1" height="35">
				<span style="margin-left: 30px">一级单位：</span>
				<span id="depart1SelectSpan">
				<%@include file="depart_select/depart1_select_section.jsp" %>
				</span>
				<br />
				<span style="margin-left: 30px">二级单位：</span>
				<span id="depart2SelectSpan">
				<%@include file="depart_select/depart2_select_section.jsp" %>
				</span>
				<br />
				<span style="margin-left: 30px">职务(岗位)：</span>
				<span id="jobpostSelectSpan">
				<%@include file="jobpost_select/jobpost_select_section.jsp" %>
				</span>
			</td>
			<td  class="td1" height="35">				
				<span style="margin-left: 30px">角色：</span>
				<span id="roleSelectSpan">
				<%@include file="role_select/role_select_section.jsp" %>
				</span>
			</td>
		</tr>
		<tr>
			<td colspan="2" class="td1" align="center">
				<input type="button" value="更新" onclick="updateJobpostRole()" />
			</td>
		</tr>
	</table>
</div>
<script type="text/javascript">
function selectDepart1() {
	var depart1ID = getElementValueByID('depart1');
	loadPageSection('depart_select/depart2_select_section.jsp', 'depart2SelectSpan', {depart1ID:depart1ID}, false, function(){ selectDepart2();});
}

function selectDepart2() {
	var depart1ID = getElementValueByID('depart1');
	var depart2ID = getElementValueByID('depart2');
	loadPageSection('jobpost_select/jobpost_select_section.jsp', 'jobpostSelectSpan', {depart1ID:depart1ID, depart2ID:depart2ID}, false, function(){selectJobpost();});
}

function selectJobpost() {
	var jobPostID = getElementValueByID('jobpost');
	loadPageSection('role_select/role_select_section.jsp', 'roleSelectSpan', {jobPostID:jobPostID, selectedBy:'<%=Constants.CONST_SELECTED_BY_JOBPOSTID%>'}, false);
}


function updateJobpostRole() {
	var depart1ID = getElementValueByID('depart1');
	var depart2ID = getElementValueByID('depart2');
	var jobPostID = getElementValueByID('jobpost');
	var roleID =  getElementValueByID('role');
	if(jobPostID == '' || jobPostID == null || jobPostID == 'undefined'){
		$.dialog.alert('请先选择职务（岗位）');
		return;
	}
	
$.dialog.confirm('您确认修改吗？', function(){
	openWaitingDialog('waitingDialog');
	$.ajax({
		type:'post',
		url:'update_jobpost_role_process.jsp',
		data:{			
			jobPostID: jobPostID,
			roleID: roleID
		},
		success:function(data,state,xmlhttp){
			var obj = null;
			try {
				obj = eval('(' + data + ')');
			} catch (e) {
			}
			if (typeof(obj.isSuccess) != 'undefined') {
				closeWaitingDialog('waitingDialog');
				if (obj.isSuccess == 'true') {					
					$.dialog('更新成功！', function() { loadPageSection('<%=request.getContextPath()%>/admin/jobpost_role.jsp', 'mainContentDiv', {depart1ID:depart1ID, depart2ID:depart2ID, jobPostID:jobPostID, roleID:roleID}, true); });					
				} else {
					$.dialog.alert(obj.error);
				}
			}
		}
	});
});
}

selectDepart1();
</script>
<%
}
%>

